const arr = [1, 2, 3, [4, 5, [1,2,3],6], 8]

// console.log(arr.flat());


Array.prototype.my_flat = function() {
    let newArr = this
    while (newArr.some(item => Array.isArray(item))) {
        newArr = [].concat(...newArr)
    } 
    console.log(newArr);
}

arr.my_flat()

Array.prototype.my_flat = function() {
    
}

